
/* start /scripts/web-platform-eqx/widgets/youtube.js*/

var yt=function($){var i,j,len;var ytAPI="https://gdata.youtube.com/feeds/api/";function Video(data){this.data=data;this.type="youtube";this.link=$.grep(data.link,function(link){return link.rel=="alternate"})[0].href;this.author=data.author[0].name.$t;this.profile_link=data.author[0].uri.$t;this.profile_username=data.author[0].uri.$t.split("https://gdata.youtube.com/feeds/api/users/")[1];this.description=(data.media$group.media$description)?data.media$group.media$description.$t:'';if(data.media$group.media$thumbnail){this.thumbnail={'default':$.grep(data.media$group.media$thumbnail,function(img){return img.yt$name=="default"})[0].url.replace("http://","https://"),'mqdefault':$.grep(data.media$group.media$thumbnail,function(img){return img.yt$name=="mqdefault"})[0].url.replace("http://","https://"),'hqdefault':$.grep(data.media$group.media$thumbnail,function(img){return img.yt$name=="hqdefault"})[0].url.replace("http://","https://")};if($.grep(data.media$group.media$thumbnail,function(img){return img.yt$name=="sddefault"})[0]){this.thumbnail.sddefault=$.grep(data.media$group.media$thumbnail,function(img){return img.yt$name=="sddefault"})[0].url.replace("http://","https://")}}else{this.thumbnail={};}
this.title=data.title.$t;this.short_desc=this.description.substring(0,140)+"...";this.duration=(data.media$group.yt$duration)?data.media$group.yt$duration.seconds:0;this.views=(data.yt$statistics)?data.yt$statistics.viewCount:0;this.favorites=(data.yt$statistics)?data.yt$statistics.favoriteCount:0;this.canEmbed=(data.yt$accessControl)?$.grep(data.yt$accessControl,function(ctrl){return ctrl.action=="embed"})[0].permission=="allowed":false;this.published=data.published.$t;this.src=(data.content)?data.content.src:'';this.id=data.media$group.yt$videoid.$t;}
Video.prototype.embedCode=function(width,height,autoplay){width=width||560;height=height||315;autoplay=autoplay||0;return'<iframe width="'+width+'" height="'+height+'" src="https://www.youtube.com/embed/'+this.id+'?autoplay='+autoplay+'&enablejsapi=1&wmode=opaque" frameborder="0" allowfullscreen></iframe>';}
Video.prototype.self=function(){return this;}
function Playlist(data){this.data=data;this.link=(data.link)?$.grep(data.link,function(link){return link.rel=="alternate"})[0].href:'';this.author=(data.author)?data.author[0].name.$t:'';this.title=(data.title)?data.title.$t:'';this.id=(data.yt$playlistId)?data.yt$playlistId.$t:'';this.videos=[];}
Playlist.prototype.toHTML=function(){var watchAllURL=this.videos[0].link+'&list='+this.id;var html='<div class="playlist">'+'<a href="'+watchAllURL+'" class="play-all" target="_blank">'+'<span class="playlist-thumb-strip">'+'<span class="videos-4">';for(var i=0,len=this.videos.length;i<len&&i<4;i++){html+='<span class="clip">'+'<span class="centering-offset">'+'<span class="centering">'+'</span></span></span>';}
html+='</span>'+'<span class="resting-overlay">'+'<span class="video-play-btn"></span>'+'<span class="video-count-box">'+this.videos.length+' videos</span>'+'</span>'+'<span class="hover-overlay">'+'<span class="play-all-container">'+'<strong><span class="video-play-all-btn"></span>Play all</strong>'+'</span></span></span></a>'+'<h3><a href="'+this.link+'" title="See all videos in playlist.">'+this.title+'</a></h3>'+'<span class="playlist-author-attribution">by '+this.author+'</span>'+'</div>';return html;}
function retrievePlayLists(channel,callback){return $.ajax({url:ytAPI+'users/'+channel+'/playlists',data:{v:2,alt:'json'},dataType:'jsonp',method:'GET'}).done(callback);}
function getVideoData(videoId,callback){return $.ajax({url:ytAPI+'videos/'+videoId+'',data:{v:2,alt:'json'},dataType:'jsonp',method:'GET'}).done(callback);}
function getLatestUploads(channel,count,callback){return $.ajax({url:ytAPI+'users/'+channel+'/uploads',data:{v:2,alt:'json',"max-results":count},dataType:'jsonp',method:'GET'}).done(callback);}
function getPlaylistById(playlistId,count,callback){return $.ajax({url:ytAPI+'playlists/'+playlistId,data:{v:2,alt:'json',"max-results":count},dataType:'jsonp',method:'GET'}).done(callback);}
function retrieveVideo(vURL,callback,index){return $.ajax({url:vURL,dataType:'jsonp',method:'GET'}).done(function(data){if(callback)callback(data,index);});}
function fetchPlaylists(channelName,callback){channelName=channelName||'PlanetSide2';callback=callback||function(data){};var playlists=[],plCalls=[],dfd=$.Deferred(),promise=dfd.promise();retrievePlayLists(channelName).done(function(resp){var numPlaylists=resp.feed.entry.length;for(i=0;i<numPlaylists;i++){playlists.push(new Playlist(resp.feed.entry[i]));}
var completed=0;for(i=0;i<numPlaylists;i++){var rVdata=retrieveVideo(playlists[i].data.content.src+'&alt=json',function(data,index){for(j=0,len=data.feed.entry.length;j<len;j++){playlists[index].videos.push(new Video(data.feed.entry[j]));}
completed++;if(completed>=playlists.length)
{dfd.resolve(playlists);}},i);plCalls.push(rVdata);}}).fail(dfd.reject);promise.done(callback);}
function getVideo(videoId,callback){callback=callback||function(data){};getVideoData(videoId,function(resp){callback(new Video(resp.entry));});}
function getUserVideos(channel,count,callback){callback=callback||function(data){};getLatestUploads(channel,count,function(resp){var response=[];_.each(resp.feed.entry,function(rawVideo){var video=new Video(rawVideo);response.push(video);})
callback(response);});}
function getPlaylistVideos(playlistId,count,callback,returnPlaylist){callback=callback||function(data){};returnPlaylist=returnPlaylist||false;if(playlistId instanceof Array){var playlists=playlistId,finished=0,playlistData=[],dfd=$.Deferred(),promise=dfd.promise();_.each(playlists,function(playlist){getPlaylistById(playlist,count,function(data){playlistData.push(data);finished++;if(finished>=playlistId.length){dfd.resolve(playlistData);}});});promise.done(function(data){var responseData=[];_.each(data,function(resp){if(returnPlaylist){var playlist=new Playlist(resp.feed);_.each(resp.feed.entry,function(rawVideo){var video=new Video(rawVideo);playlist.videos.push(video);});responseData.push(playlist);}else{var response=[];_.each(resp.feed.entry,function(rawVideo){var video=new Video(rawVideo);response.push(video);});responseData.push(response);}});callback(responseData);});}else{getPlaylistById(playlistId,count,function(resp){var response=[];_.each(resp.feed.entry,function(rawVideo){var video=new Video(rawVideo);response.push(video);})
callback(response);});}}
function videoSearch(query,options,callback){query=query||'SOE';options=options||{};callback=callback||function(data){};var videos=[];var searchData={'q':query,'orderby':(options['orderby'])?options['orderby']:'published','max-results':(options['max-results'])?options['max-results']:'25','v':'2','alt':'json','fields':(options['fields'])?options['fields']:'entry'};if(options['start-index']&&parseInt(options['start-index'])>0){searchData['start-index']=options['start-index'];}
$.ajax({url:ytAPI+'videos',dataType:'jsonp',method:'GET',data:searchData,}).done(function(data){var stahp=false;if(data.feed.entry){for(i=0,len=data.feed.entry.length;i<len;i++){videos.push(new Video(data.feed.entry[i]));}}else{stahp=true;}
var start;if(options['start-index']){start=(options['max-results'])?parseInt(options['start-index'])+parseInt(options['max-results'])-1:parseInt(options['start-index'])+24;}else{start=(options['max-results'])?options['max-results']-1:24;}
var extraCB=(options['extraCB'])?options['extraCB']:function(data){};var sData=(options['savedData'])?options['savedData']:[];callback(videos,sData,start,stahp,extraCB);});}
return{fetchPlaylists:fetchPlaylists,Playlist:Playlist,videoSearch:videoSearch,getVideo:getVideo,getUserVideos:getUserVideos,getPlaylistVideos:getPlaylistVideos,Video:Video};}(jQuery);

/* end /scripts/web-platform-eqx/widgets/youtube.js*/

/* start /web-platform/scripts/web-platform/social/twittershare.js*/

SOE.TwitterShare=function(){"use strict";this.intents={reply:"tweet?in_reply_to",retweet:"retweet?tweet_id",favorite:"favorite?tweet_id",hashtag:"tweet?hashtags",user:"user?screen_name",follow:"follow?screen_name",sharelink:"tweet?url"};this.addListener();};SOE.TwitterShare.prototype.shareTweet=function(intent,id){"use strict";if(this.intents[intent]&&id){window.open("https://twitter.com/intent/"+this.intents[intent]+"="+encodeURIComponent(id),"twitter","menubar=no,width=500,height=450,toolbar=no");}};SOE.TwitterShare.prototype.addListener=function(){"use strict";$("body").on("click",".twitter-share",function(evt){evt.preventDefault();var $elm=$(evt.currentTarget);var intent=$elm.data("twitter-action");var id=$elm.data("twitter-id");if(intent&&id){this.shareTweet(intent,id);}}.bind(this));};SOE.TwitterShare.parseTimestamp=function(timeStamp){"use strict";var date=new Date(timeStamp);if(_.isNaN(date.getTime())){date=new Date(timeStamp.replace(/( \+)/,"UTC$1"));}
return date;};SOE.TwitterShare.formatTweet=function(text,formats){'use strict';if(typeof formats==='undefined'){return text;}
var k,item,replaceList;if(formats.media){for(k=0;k<formats.media.length;k++){item=formats.media[k];if(item.url){text=text.replace(item.url,'<a href="'+item.url+'" target="_blank">'+item.url+'</a>');}}}
if(formats.urls){for(k=0;k<formats.urls.length;k++){item=formats.urls[k];text=text.replace(item.url,'<a href="'+item.url+'" target="_blank">'+item.url+'</a>');}}
if(formats.hashtags){replaceList=_.pluck(formats.hashtags,'text').sort(function(a,b){return b.length-a.length;}).join('|');text=text.replace(new RegExp('#('+replaceList+')','ig'),'<a href="javascript:;" class="twitter-share" data-twitter-action="hashtag" data-twitter-id="$1">#$1</a>');}
if(formats.user_mentions){replaceList=_.pluck(formats.user_mentions,'screen_name').sort(function(a,b){return b.length-a.length;}).join('|');text=text.replace(new RegExp('@('+replaceList+')','ig'),'<a href="javascript:;" class="twitter-share" data-twitter-action="follow" data-twitter-id="$1">@$1</a>');}
return text;};$(document).ready(function(){"use strict";new SOE.TwitterShare();});

/* end /web-platform/scripts/web-platform/social/twittershare.js*/

/* start /scripts/_pages/developers.js*/

$(function(){var tweetLimit=10,developers=_.keys(devTweets),tweetTemplate=_.template($('#tpl-tweet-item').html()),rotatingDiv='#davegeorgeson';setInterval(function(){$(rotatingDiv+' .carousel-controls .next').trigger('click');},5000);_.each(developers,function(dev){var data=devTweets[dev];if(data.length){var first10=_.first(data,tweetLimit);_.each(first10,function(tweet,index){tweet.processedText=tweet.text;tweet.formatting={'extraClass':(index===0)?'active':''};_.each(tweet.entities,function(entityType,entityName){if(!_.isEmpty(entityType)){_.each(entityType,function(entity){if(entityName=="media"||entityName=="urls"){tweet.processedText=tweet.processedText.replace(entity.url,'<a class="entity" href="'+entity.url+'" target="_blank">'+entity.url+'</a>');}else if(entityName=="user_mentions"){tweet.processedText=tweet.processedText.replace('@'+entity.screen_name,'<a href="javascript:;" class="twitter-share" data-twitter-action="follow" data-twitter-id="'+entity.screen_name+'">@'+entity.screen_name+'</a>');}else if(entityName=="hashtags"){tweet.processedText=tweet.processedText.replace('#'+entity.text,'<a href="javascript:;" class="twitter-share" data-twitter-action="hashtag" data-twitter-id="'+entity.text+'">#'+entity.text+'</a>');}});}});$('.tweet-container.'+dev+' .carousel-inner').append(tweetTemplate(tweet));});var total=Math.min(tweetLimit,data.length);$('.tweet-container.'+dev+' .carousel-info .total').html(total);}else{$('.tweet-container.'+dev+' .carousel-counter span').html('0');}});$('body').on('slid',function(e){var divID='#'+e.target.id,index=$(divID+' .carousel-inner .item.active').index()+1;$(divID+' .carousel-counter .current').html(index);});$('.tweet-container').on('click','.carousel-controls a',function(){var carousel=$(this).attr('rel'),currentItem=$(carousel+' .carousel-inner .item.active').index(),newIndex=($(this).hasClass('next'))?(currentItem+2):currentItem;if(newIndex>=0){newIndex=newIndex%$(carousel+' .carousel-inner .item').length-1;}
$(carousel+' .carousel-inner .item').removeClass('active').eq(newIndex).addClass('active');$(carousel).trigger('slid');});$('.developers').on('mouseenter','.developer',function(e){if(e.type=="mouseenter"){rotatingDiv=$(this).data('thiscarousel');}});$('.developers').on('mouseenter','.tweet-container',function(e){if(e.type=="mouseenter"){rotatingDiv='none';}});$('.developers').on('mouseleave','.tweet-container',function(e){if(e.type=="mouseleave"){rotatingDiv='#'+e.currentTarget.id;}});});

/* end /scripts/_pages/developers.js*/

/* start /web-platform/scripts/web-platform/component/global-nav.js*/

(function(){var nonMember=_.template($("script.non-member").html());var member=_.template($("script.member").html());if(globs.wdl.userLoggedIn==true){$.ajax({url:'/get-rest-ticket',type:'POST',data:{type:0},context:this,success:function(sid){$.ajax({url:globs.urls.uramAjaxUrl+"/rest/commerce/11/allaccessinfo.action",dataType:"json",data:{'responseType':"json",'sessionID':sid.successPayload.ticket,},success:function(data){var memberData={scGrantDate:data.scGrantDate,scGrantClaimed:data.scGrantClaimed,mbExpirationDate:data.expirationDate};$('.mb-scBalance').text(data.scBalance);if(data.akella==false){if(data.member==false){$('#mb-all-access').html(nonMember());$('#mb-isMember').text('Try');}else{$('#mb-all-access').html(member(memberData));$('#mb-isMember').text('My');$("#membershipLink").click(function(){window.location.href=globs.urls.membershipMembership;});};}}})}})}else{$('#mb-all-access').html(nonMember());}})();

/* end /web-platform/scripts/web-platform/component/global-nav.js*/
